home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / desktop / wspacer.zip / WSMAKE.WBT < prev    next >
Text File  |  1991-09-13  |  5KB  |  166 lines

  1. ; --- This is WSMAKE.WBT (a Batch Builder file that obtains WorkSpace
  2. ;     information, storing it in a private INI file).  WSRUN.WBT (a
  3. ;     Batch Builder file that restores a named Workspace to the desktop)
  4. ;     is paired with WSMAKE.WBT to complete WorkSpacer.
  5.  
  6. ; --- WiGuys SoftWare
  7. ;     19 Rushbrook Drive,
  8. ;     Kitchener, ON N2E 3C1
  9. ;     (519) 745-9717
  10. ;     Gregg J. Hommel, CIS # 72537,552
  11. ; --- WorkSpacer is freeware.
  12.  
  13. ; --- Setup default variable strings and integers.
  14.  
  15. WinHide ( "WBT" )
  16. spacelib = "c:\ndw\wspace.lib"
  17. spacebak = "c:\ndw\wspace.bak"
  18. maxhere = 4
  19. newcount = 1
  20.  
  21. hortab = Num2Char (9)
  22. crlf = StrCat ( Num2Char (13), Num2Char (10) )
  23. tlfs = StrCat ( "%crlf%", "%crlf%" )
  24. msg = ""
  25.  
  26. If FileExist (spacelib ) Then GoTo libwarn
  27. msg = StrCat ( "There are no WorkSpaces created.", "%tlfs%" )
  28.  
  29. :libwarn
  30. msg = StrCat ( "%msg%", "To create a WorkSpace, you must first : ", "%tlfs%" )
  31. msg = StrCat ( "%msg%", "1) Load and position all the applications", "%crlf%" )
  32. msg = StrCat ( "%msg%", "2) Run WorkSpacer to create the WorkSpace.", "%tlfs%" )
  33. msg = StrCat ( "%msg%", " Is it OK to proceed with creating a WorkSpace?" )
  34.  
  35. ques = AskYesNo ( "WorkSpacer", "%msg%" )
  36. if ques == @NO Then GoTo last
  37. allwin = WinItemize ()
  38.  
  39. :doagain       ; get the list of current windows
  40. If newcount > 1 Then GoTo getdata
  41.  
  42. :wsname
  43. msg = StrCat ( "What is the WorkSpace name?", "%crlf%" )
  44. msg = StrCat ( "%msg%", "(Maximum - 30 characters)" )
  45. grpname = AskLine ( "WorkSpacer Says", "%msg%", "" )
  46. grpsize = StrLen ( grpname )
  47.  
  48. If !grpsize == 0 || grpsize < 31 Then GoTo checkgrp
  49. Message ( "WorkSpacer Warning", "Invalid WorkSpace name")
  50. GoTo wsname
  51.  
  52. :checkgrp      ; Check for duplicate WorkSpace name.
  53. If !FileExist ( spacelib ) Then GoTo getdata
  54. fHandle = FileOpen ( spacelib, "READ" )
  55.  
  56. :retry
  57. line = FileRead ( fHandle )
  58. If StrICmp ( grpname, line ) == 0 Then GoTo askagain
  59. If line == "*EOF*" Then GoTo getdata
  60. GoTo retry
  61.  
  62. :askagain
  63. reshere = AskYesNo ( "WorkSpacer", "Duplicate WorkSpace name! Try another?" )
  64. If reshere == @YES Then GoTo doagain
  65. GoTo last
  66.  
  67. :getdata      ; get the information for the current application.
  68.  
  69. currwind = ItemSelect ( "Select an application", allwin, hortab )
  70. If !StrICmp ( currwind, "" ) == 0 Then GoTo apppos
  71. Message ( "WorkSpacer Warning", "Nothing was selected!" )
  72. goto getdata
  73.  
  74. :apppos        ; get the position of the app
  75. currpos = WinPosition ( "%currwind%" )
  76.  
  77. :getname       ; get the filename and path info
  78. msg = StrCat ( "What is the application filename?", "%tlfs%" )
  79. msg = StrCat ( "%msg%", "Include the extension ( EXE )", "%crlf%" )
  80. msg = StrCat ( "%msg%", "and drive/path (if needed)." )
  81. filename = AskLine ( "WorkSpacer", "%msg%", "" )
  82.  
  83. root = FileRoot ( filename )   ; validity checks
  84. If StrLen ( "%root%" ) > 0 && StrLen ("%root%" ) < 9 Then GoTo extcheck
  85. Message ( "WorkSpacer Warning", "Invalid file name" )
  86. GoTo getname
  87.  
  88. :extcheck
  89. ext = FileExtension ( filename )
  90. If StrICmp ( ext, "exe" ) == 0 Then GoTo pathcheck
  91. ext = "exe"
  92. filename = StrCat ( filename, ".", ext )
  93.  
  94. :pathcheck
  95. path = FilePath ( filename )
  96. truepath = FileLocate ( filename )
  97. If !StrICmp ( truepath, "" ) == 0 Then GoTo foundit
  98.  
  99. tryok = AskYesNo ( "WorkSpacer", "Incorrect Path/Filename. Reenter it?" )
  100. If tryok == @NO Then GoTo last
  101. GoTo getname
  102.  
  103. :foundit       ;filename is fine, so update INI and LIB
  104. If newcount == 1 Then GoTo writelib
  105. tcount = 1
  106.  
  107. :loop          ; check for duplicate filename in INI
  108. tkey = StrCat ( "App", tcount )
  109. tline = IniReadPvt ( grpname, tkey, filename, "wspace.ini" )
  110. If StrICmp ( tline, filename ) == 0 Then GoTo dupefile
  111. tcount = tcount + 1
  112. If tcount == newcount Then GoTo writeini
  113. GoTo loop
  114.  
  115. :dupefile
  116. msg = StrCat ("That application is in the WorkSpace already!","%tlfs%" )
  117. msg = StrCat ("%msg%", "Choose another application?" )
  118. choose = AskYesNo ( "WorkSpacer", "%msg%" )
  119. If choose == @NO Then GoTo last
  120. GoTo getdata
  121.  
  122. :writelib      ; take care of the LIB file
  123. If FileExist ( spacelib ) Then GoTo oldspace
  124.  
  125. :newspace      ; create a new LIB if needed
  126. fHandle = FileOpen ( spacelib, "WRITE" )
  127. FileWrite ( fHandle, "%grpname%" )
  128. FileClose ( fHandle )
  129. GoTo writeini
  130.  
  131. :oldspace      ; update the old LIB file
  132. FileRename ( spacelib, spacebak )
  133. fHandle1 = FileOpen ( spacebak, "READ" )
  134. fHandle2 = FileOpen ( spacelib, "WRITE" )
  135.  
  136. :top
  137. line = FileRead ( fHandle1 )
  138. If line == "*EOF*" Then GoTo stop
  139. FileWrite ( fHandle2, "%line%" )
  140. GoTo top
  141.  
  142. :stop
  143. FileClose ( fHandle1 )
  144. FileWrite ( fHandle2, "%grpname%" )
  145. FileClose ( fHandle2 )
  146. FileDelete ( spacebak )
  147.  
  148. :writeini      ; create or update the INI file
  149. key1 = StrCat ( "App", newcount )
  150. key2 = StrCat ( "Pos", newcount )
  151. key3 = StrCat ( "Win", newcount )
  152.  
  153. IniWritePvt ( grpname, key1, filename, "wspace.ini" )
  154. IniWritePvt ( grpname, key2, currpos, "wspace.ini" )
  155. IniWritePvt ( grpname, key3, currwind, "wspace.ini" )
  156.  
  157. If newcount == maxhere Then GoTo last
  158. newcount = newcount + 1
  159. more = AskYesNo ( "WorkSpacer Says", "Add another application?" )
  160. If more == @NO Then GoTo last
  161. GoTo doagain
  162.  
  163. :last          ; YEAH !!! Finished, at last!
  164. Return
  165.  
  166.